package cn.funnyxb.powerremember.uis.task.done.study;

import android.app.Activity;
import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.app.ProgressDialog;
import android.database.Cursor;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ArrayAdapter;
import android.widget.CheckBox;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RadioButton;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.Spinner;
import android.widget.TextView;
import android.widget.Toast;
import cn.funnyxb.powerremember.ad.ADController;
import cn.funnyxb.powerremember.beans.ATask;
import cn.funnyxb.powerremember.db.tables.Tbholder_taskWithWords;
import cn.funnyxb.powerremember.pullMsg.beans.AppConfig;
import cn.funnyxb.powerremember.tts.TTSHolder;
import cn.funnyxb.powerremember.tts.TTSHolder.NotifyOnceHelper;
import cn.funnyxb.powerremember.uis.task.done.InputIntentChecker;
import cn.funnyxb.tools.appFrame.App;
import cn.funnyxb.tools.appFrame.activityFrame.ActivitysHolder;
import cn.funnyxb.tools.appFrame.debugTool.Debuger;
import com.adview.AdViewLayout;
import com.mobclick.android.MobclickAgent;
import com.mt.airad.AirAD;
import java.util.ArrayList;
import java.util.Iterator;

public class StudyActivity extends Activity
  implements IUI_Study
{
  private static final int ITEMID_HELP = 4;
  private static final int ITEMID_MODE = 1;
  private static final int ITEMID_SELECT = 2;
  private static final int ITEMID_STYLE = 3;
  private AirAD ad = null;
  ADController adController = App.getApp().getADController();
  int adid = 0;
  private View.OnClickListener btnOnClickListener = new 1(this);
  private StudyConfiger config;
  private long endTime;
  private InputIntentChecker intentChecker;
  int lastClickAdid = -1;
  private TTSHolder.NotifyOnceHelper notifyHelper = new TTSHolder.NotifyOnceHelper();
  private int pageCnt;
  private int pageIndex;
  private IProccessor_Study proccessor;
  ProgressDialog progressDialog;
  private CursorAdapter_4Study sca;
  private long startTime;
  Tbholder_taskWithWords tbholder_task;

  static
  {
    AirAD.setGlobalParameter("16fc216e-6650-4c8b-ab35-2228df9f5e67", 10.0D);
  }

  private void createAdapter(Cursor paramCursor)
  {
    ListView localListView = (ListView)findViewById(2131165253);
    String[] arrayOfString = new String[5];
    arrayOfString[0] = "_id";
    arrayOfString[1] = "word";
    arrayOfString[2] = "pronounce";
    arrayOfString[3] = "meaning";
    arrayOfString[4] = "difficulty";
    int[] arrayOfInt = new int[5];
    arrayOfInt[0] = 2131165274;
    arrayOfInt[1] = 2131165275;
    arrayOfInt[2] = 2131165279;
    arrayOfInt[3] = 2131165280;
    arrayOfInt[4] = 2131165277;
    this.sca = new CursorAdapter_4Study(this, 2130903051, paramCursor, arrayOfString, arrayOfInt, this.config, this.tbholder_task);
    localListView.setAdapter(this.sca);
    localListView.setOnItemClickListener(new 4(this));
  }

  private void dismissWaittingDialog()
  {
    if ((this.progressDialog == null) || (!(this.progressDialog.isShowing())))
      return;
    this.progressDialog.dismiss();
  }

  private void freashBtnEnable()
  {
    View localView1 = findViewById(2131165248);
    boolean bool1;
    label17: View localView2;
    if (this.pageIndex == 1)
    {
      bool1 = false;
      localView1.setEnabled(bool1);
      localView2 = findViewById(2131165251);
      if (this.pageIndex != this.pageCnt)
        break label55;
    }
    for (boolean bool2 = false; ; bool2 = true)
    {
      localView2.setEnabled(bool2);
      return;
      bool1 = true;
      label55: break label17:
    }
  }

  private void freashListView(Cursor paramCursor)
  {
    if (this.sca == null)
      createAdapter(paramCursor);
    while (true)
    {
      ((ListView)findViewById(2131165253)).setSelection(0);
      return;
      this.sca.changeCursor(paramCursor);
    }
  }

  private void hideAD_adView()
  {
    findViewById(2131165246).setVisibility(8);
  }

  private void initBtns()
  {
    findViewById(2131165251).setOnClickListener(this.btnOnClickListener);
    findViewById(2131165248).setOnClickListener(this.btnOnClickListener);
  }

  private void initFrame()
  {
    initSpinner();
    initBtns();
  }

  private void initSpinner()
  {
    Spinner localSpinner = (Spinner)findViewById(2131165252);
    Object[] arrayOfObject = new Object[StudyConfiger.PAGESIZES.length];
    String str = getString(2131034308);
    for (int i = 0; ; ++i)
    {
      if (i >= StudyConfiger.PAGESIZES.length)
      {
        localSpinner.setAdapter(new ArrayAdapter(this, 17367048, 16908308, arrayOfObject));
        localSpinner.setOnItemSelectedListener(new 5(this));
        return;
      }
      arrayOfObject[i] = str + StudyConfiger.PAGESIZES[i];
    }
  }

  private void log(String paramString)
  {
    Debuger.log("study", paramString);
  }

  private void prepareAD()
  {
    log("prepareAD,isCloseAd=" + this.adController.isCloseAd(this));
    if (!(App.getApp().getAppConfig().isAdFunction()));
    while (true)
    {
      return;
      AppConfig localAppConfig = App.getApp().getAppConfig();
      if (localAppConfig.isAdFunction_study_adview())
        prepareAdView();
      if (!(localAppConfig.isAdFunction_study_airad()))
        continue;
      prepareAirad();
    }
  }

  private void prepareAdView()
  {
    log("prepare ADview");
    LinearLayout localLinearLayout = (LinearLayout)findViewById(2131165214);
    if (localLinearLayout == null);
    while (true)
    {
      return;
      AdViewLayout localAdViewLayout = new AdViewLayout(this, "SDK20112317530746gbtoshlnjwggb48");
      localLinearLayout.addView(localAdViewLayout, new RelativeLayout.LayoutParams(-1, -2));
      localLinearLayout.invalidate();
      localAdViewLayout.setAdViewInterface(new 2(this));
    }
  }

  private void prepareAirad()
  {
    log("prepare AirAD");
    this.ad = new AirAD(this, 12, 1);
    this.ad.setAdListener(new 3(this));
  }

  private void showHelp()
  {
    new AlertDialog.Builder(this).setTitle(2131034130).setMessage(2131034317).setNegativeButton(2131034158, null).create().show();
  }

  private void showModeSet()
  {
    View localView = getLayoutInflater().inflate(2130903049, null);
    boolean bool = App.getApp().getTTSHolder().isTtsFunctionClose();
    CheckBox localCheckBox1 = (CheckBox)localView.findViewById(2131165258);
    localCheckBox1.setChecked(this.config.isSpeechWhenClick());
    int i;
    label52: CheckBox localCheckBox2;
    CheckBox localCheckBox3;
    if (bool)
    {
      i = 8;
      localCheckBox1.setVisibility(i);
      localCheckBox2 = (CheckBox)localView.findViewById(2131165260);
      localCheckBox2.setChecked(this.config.isEnableAdjustDifficultyByBtn());
      localCheckBox3 = (CheckBox)localView.findViewById(2131165259);
      localCheckBox3.setChecked(this.config.isShowPhoneticAfterClick());
      switch (this.config.getMode())
      {
      default:
      case 1:
      case 2:
      case 3:
      }
    }
    while (true)
    {
      new AlertDialog.Builder(this).setTitle(2131034310).setView(localView).setPositiveButton(2131034133, new 6(this, localView, localCheckBox1, localCheckBox3, localCheckBox2)).setNegativeButton(2131034153, null).create().show();
      return;
      i = 0;
      break label52:
      ((RadioButton)localView.findViewById(2131165255)).setChecked(true);
      continue;
      ((RadioButton)localView.findViewById(2131165256)).setChecked(true);
      continue;
      ((RadioButton)localView.findViewById(2131165257)).setChecked(true);
    }
  }

  private void showNextPage()
  {
    if (this.pageIndex >= this.pageCnt)
      Toast.makeText(this, 2131034307, 1).show();
    while (true)
    {
      return;
      IProccessor_Study localIProccessor_Study = this.proccessor;
      int i = 1 + this.pageIndex;
      this.pageIndex = i;
      localIProccessor_Study.asyncPreparePage(i);
    }
  }

  private void showPrePage()
  {
    if (this.pageIndex <= 1)
      Toast.makeText(this, 2131034306, 1).show();
    while (true)
    {
      return;
      IProccessor_Study localIProccessor_Study = this.proccessor;
      int i = this.pageIndex - 1;
      this.pageIndex = i;
      localIProccessor_Study.asyncPreparePage(i);
    }
  }

  private void showSelect()
  {
    Toast.makeText(this, 2131034315, 1).show();
    View localView = getLayoutInflater().inflate(2130903050, null);
    boolean[] arrayOfBoolean = new boolean[10];
    ArrayList localArrayList = this.proccessor.getDifficultys();
    Iterator localIterator;
    if ((localArrayList != null) && (localArrayList.size() > 0))
    {
      ((CheckBox)localView.findViewById(2131165261)).setChecked(true);
      localView.findViewById(2131165262).setVisibility(0);
      localIterator = localArrayList.iterator();
    }
    while (true)
    {
      if (!(localIterator.hasNext()))
      {
        ((CheckBox)localView.findViewById(2131165261)).setOnCheckedChangeListener(new 7(this, localView));
        ((CheckBox)localView.findViewById(2131165263)).setOnCheckedChangeListener(new 8(this, localView, arrayOfBoolean));
        new AlertDialog.Builder(this).setTitle(2131034316).setView(localView).setPositiveButton(2131034133, new 9(this, localView)).setNegativeButton(2131034153, null).create().show();
        return;
      }
      arrayOfBoolean[((java.lang.Integer)localIterator.next()).intValue()] = true;
    }
  }

  private void showWaittingDialog()
  {
    this.progressDialog = new ProgressDialog(this);
    this.progressDialog.setMessage(getString(2131034132));
    this.progressDialog.show();
  }

  private void speechItem(int paramInt)
  {
    if (!(this.config.isSpeechWhenClick()));
    while (true)
    {
      return;
      TTSHolder localTTSHolder = App.getApp().getTTSHolder();
      String str = this.sca.getWord(paramInt);
      if (str == null)
        continue;
      localTTSHolder.speech(this, this.notifyHelper, str, 0, null);
    }
  }

  public void notifyConfigLoaded(StudyConfiger paramStudyConfiger)
  {
    if ((isFinishing()) || (isRestricted()));
    while (true)
    {
      return;
      this.config = paramStudyConfiger;
      initFrame();
      ((Spinner)findViewById(2131165252)).setSelection(paramStudyConfiger.getPageSizeId());
      Toast.makeText(this, 2131034309, 1).show();
    }
  }

  public void notifyErrCall()
  {
    if ((isFinishing()) || (isRestricted()));
    while (true)
    {
      return;
      Toast.makeText(this, 2131034147, 1).show();
      finish();
    }
  }

  public void notifyItentOk(InputIntentChecker paramInputIntentChecker)
  {
    if ((isFinishing()) || (isRestricted()))
      label14: return;
    this.intentChecker = paramInputIntentChecker;
    this.tbholder_task = new Tbholder_taskWithWords(App.getApp().getDBHolder(), paramInputIntentChecker.getTaskInfo().getName());
    String str = "";
    switch (paramInputIntentChecker.getRangeType())
    {
    default:
    case 1:
    case 2:
    case 3:
    }
    while (true)
    {
      setTitle(getString(2131034112) + " - " + str);
      break label14:
      str = getString(2131034160) + paramInputIntentChecker.getGroupId() + getString(2131034149);
      continue;
      str = getString(2131034160) + paramInputIntentChecker.getGroupStart() + " -- " + paramInputIntentChecker.getGroupEnd() + getString(2131034149);
      continue;
      str = getString(2131034160) + paramInputIntentChecker.getWordStart() + " -- " + paramInputIntentChecker.getWordEnd() + getString(2131034150);
    }
  }

  public void notifyListData(int paramInt, Cursor paramCursor)
  {
    if ((isFinishing()) || (isRestricted()));
    while (true)
    {
      return;
      dismissWaittingDialog();
      this.pageIndex = paramInt;
      ((TextView)findViewById(2131165249)).setText(paramInt);
      freashBtnEnable();
      freashListView(paramCursor);
    }
  }

  public void notifyPageCnt(int paramInt)
  {
    if ((isFinishing()) || (isRestricted()));
    while (true)
    {
      return;
      ((TextView)findViewById(2131165250)).setText(paramInt);
      this.pageCnt = paramInt;
    }
  }

  public void notifyWaitingLoadData()
  {
    if ((isFinishing()) || (isRestricted()));
    while (true)
    {
      return;
      showWaittingDialog();
    }
  }

  protected void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    this.proccessor = new Proccessor_Study(this);
    setContentView(2130903048);
    this.proccessor.asyncPrepare(getIntent());
    prepareAD();
  }

  public boolean onCreateOptionsMenu(Menu paramMenu)
  {
    paramMenu.add(0, 1, 0, 2131034310);
    paramMenu.add(0, 2, 0, 2131034311);
    paramMenu.add(0, 3, 0, 2131034312);
    paramMenu.add(0, 4, 0, 2131034313);
    return super.onCreateOptionsMenu(paramMenu);
  }

  protected void onDestroy()
  {
    try
    {
      if (this.ad != null)
        this.ad.destory();
    }
    catch (Exception localException1)
    {
      try
      {
        this.sca.getCursor().close();
        label26: super.onDestroy();
        return;
      }
      catch (Exception localException2)
      {
        break label26:
        localException1 = localException1;
      }
    }
  }

  public boolean onOptionsItemSelected(MenuItem paramMenuItem)
  {
    switch (paramMenuItem.getItemId())
    {
    default:
    case 1:
    case 2:
    case 3:
    case 4:
    }
    while (true)
    {
      return super.onOptionsItemSelected(paramMenuItem);
      showModeSet();
      continue;
      showSelect();
      continue;
      Toast.makeText(this, 2131034314, 0).show();
      this.sca.turnStyle();
      continue;
      showHelp();
    }
  }

  protected void onPause()
  {
    super.onPause();
    MobclickAgent.onPause(this);
    this.endTime = System.currentTimeMillis();
    this.proccessor.notifyStudyLog(this.startTime, this.endTime);
  }

  protected void onResume()
  {
    super.onResume();
    MobclickAgent.onResume(this);
    App.getApp().getActivitysHolder().regCurrentActivity(this);
    this.startTime = System.currentTimeMillis();
  }

  protected void onStart()
  {
    super.onStart();
  }

  protected void onStop()
  {
    super.onStop();
  }
}

/* Location:           E:\Desktop\复件 classes_dex2jar.jar
 * Qualified Name:     cn.funnyxb.powerremember.uis.task.done.study.StudyActivity
 * JD-Core Version:    0.5.3
 */